<?php
Yii::import('application.vendors.Zend.*');
include_once('Zend/Loader.php');
class FeedsController extends Controller {

	public function actions() {


	}

	/**
	 *
	 * 转换数组到xml
	 * @param mixed $ArrayData
	 * @return string
	 * @todo you will be completed this function in next futures;
	 */
	protected function dataToXml($ArrayData=array()){
		if(!empty($ArrayData)){
			foreach ($ArrayData as $data){

			}
		}
		return $xmlString;
	}
	public function actionIndex() {

	}
	/**
	 *
	 * 根据请求日期输出所查询日期的星座日程
	 */
	public function actionLoadSingleData(){
		$LoadType = Yii::app()->request->getQuery('type');
		$LoadDate = Yii::app()->request->getQuery('date');
		if($LoadType){
			$data = OliyoServer::getTodayAstor($LoadDate);
			switch ($LoadType){
				case 'json':{
					echo json_encode($data);
				};break;
				case 'xml':{$Tdata['statu_code']=404;$Tdata['errorMsg']='sorry,this method is  not found,maybe that will be devloped in a while moment,please wait!';echo json_encode($Tdata);};break;
				case 'entype':{
					echo base64_encode(json_encode($data));
				};break;
				case 'amf':{
					Zend_Loader::loadClass('Zend_Amf_Server');
					$amf = new Zend_Amf_Server();
					try{
						$amf->setClass('AmfServer');
						$response = $amf->handle();
						echo $response;
					}catch(Exception $ex){
						print $ex;
					}
				};break;
				default:{$Tdata['statu_code']=505;$Tdata['errorMsg']="{$LoadType} is unkown in the request type.Please check it";echo json_encode($Tdata);};break;
			}
		}
	}
	public function actionAritcleSiteXml() {
		$Article = Article::model()->findAll();
		$article_tmp = array();
		if ($Article) {
			foreach ($Article as $art) {
				$article_tmp[] = "<url><loc>" . $this->createAbsoluteUrl("article/details", array("i" => $art->id, "t" => $art->title)) . "</loc><lastmod>{$atr->created}</lastmod><changefreq>daily </changefreq><priority>0.3</priority></url>";
			}
			$contents = implode("\r\n", $article_tmp);
		}
		$this->renderPartial('sitearticlexml', array('contents' => $contents));
	}

	public function actionForecastSiteXml() {
		$Forecasr = Article::model()->findAll();
		$article_tmp = array();
		if ($Article) {
			foreach ($Article as $art) {
				$article_tmp[] = "<url><loc>" . $this->createAbsoluteUrl("article/details", array("i" => $art->id, "t" => $art->title)) . "</loc><lastmod>{$atr->created}</lastmod><changefreq>daily </changefreq><priority>0.7</priority></url>";
			}
			$contents = implode("\r\n", $article_tmp);
		}
		$this->renderPartial('sitearticlexml', array('contents' => $contents));
	}

	/**
	 * 	create the feeds
	 */
	public function actionFeeds() {

	}

	public function actionMetaInMBlog() {
		$PostHeader = Yii::app()->request->getPost('PostHeader');
		$PostContent = Yii::app()->request->getPost('PostContent');

	}
	public function actionGetValidKey(){

	}
	public function actionMetaInForeCast() {

	}

}